package cn.bon.emp.mapper;


import cn.bon.emp.api.pojo.po.EmpOrg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 用户所属机构冗余表 Mapper 接口
 * </p>
 *
 * @author luochao
 * @since 2023-12-09
 */
public interface EmpOrgMapper extends BaseMapper<EmpOrg> {

    /**
     * 获取指定组织下的所有员工Id
     * @param orgId
     * @return List<Long> 员工Id
     */
    List<Long> getEmpIdsOf(Long orgId);

    /**
     * 重置groupId下的人员
     * @param groupId
     */
    @Update("UPDATE emp_org " +
            "SET group_id=NULL, update_time=#{time} " +
            "WHERE group_id=#{groupId}")
    void rmOfGroupId(@Param("groupId") Long groupId,@Param("time") String time);

    @Update("UPDATE emp_org " +
            "SET group_id=NULL, section_id=NULL, update_time=#{time} " +
            "WHERE section_id=#{sectionId}")
    void rmOfSectionId(@Param("sectionId") Long sectionId,@Param("time") String time);
}
